/*
 * Copyright 2000-2017 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.github.aloxc.plugin.restplus.navigator;

import com.github.aloxc.plugin.DonotGuard;
import com.github.aloxc.plugin.restplus.common.ServiceHelper;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.components.ProjectComponent;
import com.intellij.openapi.project.DumbService;
import com.intellij.openapi.project.Project;

import java.util.List;
/**
 *
 * @author leero
 */
@DonotGuard
public class RestServiceProjectsManager implements Disposable, ProjectComponent {

  protected final Project myProject;


  public static RestServiceProjectsManager getInstance(Project p) {
    return p.getComponent(RestServiceProjectsManager.class);
  }

  public RestServiceProjectsManager(Project project) {
//      super(project);
      myProject = project;
  }


  @Override
  public void dispose() {

  }


  public List<RestServiceProject> getServiceProjects() {
    DumbService.getInstance(myProject).runReadActionInSmartMode(()->{

    });
    List<RestServiceProject> list = DumbService.getInstance(myProject).runReadActionInSmartMode(() -> ServiceHelper.buildRestServiceProjectListUsingResolver(myProject));
    return list;
  }

  public void forceUpdateAllProjects() {

  }
}
